<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :edit="edit" :checkedit="checkedit" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {
		buildSubFormData,
		subOnLoad,
		changeEditor,
		configSelectData
	} from '../../../static/js/formUtil.js';
	import {
		ignoreHtml,
		ptFloat,
		minusF,
		getDateStr
	} from '@/static/js/common.js';
	import urlUtil from '@/static/js/urlUtil.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				userPostCache:'mkt-zs-productGive-title5-userPost-cache'
			})
		},
		methods:{
			clearUserId(){
				let _that = this
				_that.$refs.autoform.clear("title5","userPostId")
				_that.$refs.autoform.clear("title5","postId")
			},
			initload(){
				let _that = this
			},
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				if (e.configDataCacheKey) {
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if (res.data && res.data instanceof Array) {
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
							}
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							changeEditor("title5","userPostId",{
								link:'../../public/pageSearch/pageSearch',
								"linkParam":{
									other:JSON.stringify({
										postId: '',
										firstUserId:''
									}),
									url:'temployee/getStaffCombogrid',
									namefield:'username',
									notefield:'posInstName',
									searchfield:'q',
									cachename:_that.userPostCache
								}
							},null,_that.autoformdata) 
							
						}
					})
				}
			})
		},
		onShow() {
			let _that = this
			if (_that.$refs.autoform) {
				uni.getStorage({
					key:_that.userPostCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.userPostId = d.id
							formdata.userId = d.id
							formdata.userName = d.username
							formdata.postId = d.salaryPosId
							formdata.postName = d.salaryPosName
							uni.removeStorage({
								key:_that.userPostCache
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
</style>
